package org.example.B2;
import com.github.oxo42.stateless4j.delegates.FuncBoolean;
public class GuardCondition {
    private String inputPassword;
    private int passwordAttempts;
    private int lockTime;
    private String password;

    /**
     * 当输入长度==4时
     */
    FuncBoolean inputLength_eq_4(){
        return() -> (inputPassword.length() == 4);
    }

    /**
     * 当输入长度<4时
     */
    FuncBoolean inputLength_less_4(){
        return() -> (inputPassword.length() < 4);
    }

    /**
     *当密码错误次数到达3次时
     */
    FuncBoolean passwordAttempts_to_3(){
        return() -> (passwordAttempts ==3);
    }

    /**
     * 密码错误次数未超过3次
     */
    FuncBoolean passwordAttempts_less_3(){
        return() -> (passwordAttempts < 3);
    }

    /**
     * 当锁定时间超过120秒时
     */
    FuncBoolean lockTimePass120s(){
        return() -> (lockTime >= 120);
    }

    /**
     * 当锁定时间未超过120秒时
     */
    FuncBoolean lockTimeNoPass120s(){
        return() -> (lockTime < 120);
    }
    /**
     * 当密码正确时
     */
    FuncBoolean passwordCorrent(){
        return() -> (inputPassword.equals(password));
    }



    public void setInputPassword(String inputPassword) {
        this.inputPassword = inputPassword;
    }

    public String getInputPassword() {
        return inputPassword;
    }

    public void setPasswordAttempts(int passwordAttempts) {
        this.passwordAttempts = passwordAttempts;
    }
    public int getPasswordAttempts() {
        return passwordAttempts;
    }

    public void setLockTime(int lockTime) {
        this.lockTime = lockTime;
    }

    public int getLockTime() {
        return lockTime;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPassword() {
        return password;
    }


}
